import axios  from "axios";
const GoodsStory ={
    namespaced: true,
    state:()=>({
        Good_list:[],
        total:0
    }),
    mutations:{
        GoodsMution(state,list){
            state.Good_list =list
        },
        GoodsMution_list(state,total){
            state.total=total
        }
    },
    actions:{
        GoodsAction(context,page={page:1,size:2}){
            var url ="/goodslist?page="+page.page+"&size="+page.size
            axios.get(url).then(
                res=>{
                    if(res.code == 403){
                        localStorage.removeItem('log_list')
                        window.location.href = "/#/login"
                       
                    }else{
                        context.commit('GoodsMution',res.list)
                    }
                    
                }
            )
        },
        GoodsAction_list(context){
            axios.get('/goodscount').then(
                res=>{
                    context.commit('GoodsMution_list',res.list[0].total)
                }
            )
        }

    }

}
export default GoodsStory